home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Includes / UWindow.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  30.2 KB  |  931 lines  |  [TEXT/MPS ]

  1. // UWindow.h
  2. // Copyright Â© 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __UWINDOW__
  5. #define __UWINDOW__
  6.  
  7. // MacApp
  8.  
  9. #ifndef __UCOMMAND__
  10. #include "UCommand.h"
  11. #endif
  12.  
  13. #ifndef __USCRIPTABLEOBJECT__
  14. #include "UScriptableObject.h"
  15. #endif
  16.  
  17. #ifndef __UVIEW__
  18. #include "UView.h"
  19. #endif
  20.  
  21. // Toolbox
  22.  
  23. // defines WindowRef
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27.  
  28. //----------------------------------------------------------------------------------
  29. // External and forward class declarations. 
  30. //----------------------------------------------------------------------------------
  31.  
  32. class TDialogBehavior;
  33. class TDocument;
  34. #if qDrag
  35.     class TList;
  36. #endif
  37. class TToolboxEvent;
  38.  
  39. //----------------------------------------------------------------------------------
  40. // Constants
  41. //----------------------------------------------------------------------------------
  42.  
  43. const short kFloatingWindowKind = 128;            // the windowKind of floating windows 
  44. const DescType cPalette = 'cPal';
  45.  
  46. #if qDrag
  47. enum EDragCallbackStatus {eWindowNotInited, eNotInstalled, eInstalled};
  48. #endif // qDrag
  49.  
  50. struct WindowFlags
  51. {
  52.     private:
  53.         unsigned short fWindowFlagBits;
  54.         
  55.         enum
  56.         {
  57.             kHasGoAwayMask = 0x8000,
  58.             kResizableMask = 0x4000,
  59.             kDoFirstClickMask = 0x2000,
  60.             kFreeOnClosingMask = 0x1000,
  61.             kDisposeOnFreeMask = 0x0800,
  62.             kClosesDocumentMask = 0x0400,
  63.             kOpenInitiallyMask = 0x0200,
  64.             kMustAdaptToScreenMask = 0x0100,
  65.             kStaggerMask = 0x0080,
  66.             kMustForceOnScreenMask = 0x0040,
  67.             kVertCenterMask = 0x0020,
  68.             kHorzCenterMask = 0x0010,
  69.             kFloatsMask = 0x0008,
  70.             kHideOnSuspendMask = 0x0004,
  71.             kGenerateActivatesMask = 0x0002
  72.             // note that the low bit is used as filler…
  73.         };
  74.         
  75.     public:
  76.         void Initialize (void);
  77.         
  78.         Boolean GetHasGoAway (void);
  79.         Boolean GetResizable (void);
  80.         Boolean GetDoFirstClick (void);
  81.         Boolean GetFreeOnClosing (void);
  82.         Boolean GetDisposeOnFree (void);
  83.         Boolean GetClosesDocument (void);
  84.         Boolean GetOpenInitially (void);
  85.         Boolean GetMustAdaptToScreen (void);
  86.         Boolean GetStagger (void);
  87.         Boolean GetMustForceOnScreen (void);
  88.         Boolean GetVertCenter (void);
  89.         Boolean GetHorzCenter (void);
  90.         Boolean GetFloats (void);
  91.         Boolean GetHideOnSuspend (void);
  92.         Boolean GetGenerateActivates (void);
  93.         
  94.         void SetHasGoAway (unsigned short hasGoAway);
  95.         void SetResizable (unsigned short resizable);
  96.         void SetDoFirstClick (unsigned short doFirstClick);
  97.         void SetFreeOnClosing (unsigned short freeOnClosing);
  98.         void SetDisposeOnFree (unsigned short disposeOnFree);
  99.         void SetClosesDocument (unsigned short closesDocument);
  100.         void SetOpenInitially (unsigned short openInitially);
  101.         void SetMustAdaptToScreen (unsigned short mustAdaptToScreen);
  102.         void SetStagger (unsigned short stagger);
  103.         void SetMustForceOnScreen (unsigned short mustForceOnScreen);
  104.         void SetVertCenter (unsigned short vertCenter);
  105.         void SetHorzCenter (unsigned short horzCenter);
  106.         void SetFloats (unsigned short floats);
  107.         void SetHideOnSuspend (unsigned short hideOnSuspend);
  108.         void SetGenerateActivates (unsigned short generateActivates);
  109. };
  110.  
  111. inline void WindowFlags::Initialize (void)
  112. {
  113.     fWindowFlagBits = 0x0000;
  114. }
  115.  
  116. inline Boolean WindowFlags::GetHasGoAway (void)
  117. {
  118.     return (fWindowFlagBits & kHasGoAwayMask) >> 15;
  119. }
  120.  
  121. inline Boolean WindowFlags::GetResizable (void)
  122. {
  123.     return (fWindowFlagBits & kResizableMask) >> 14;
  124. }
  125.  
  126. inline Boolean WindowFlags::GetDoFirstClick (void)
  127. {
  128.     return (fWindowFlagBits & kDoFirstClickMask) >> 13;
  129. }
  130.  
  131. inline Boolean WindowFlags::GetFreeOnClosing (void)
  132. {
  133.     return (fWindowFlagBits & kFreeOnClosingMask) >> 12;
  134. }
  135.  
  136. inline Boolean WindowFlags::GetDisposeOnFree (void)
  137. {
  138.     return (fWindowFlagBits & kDisposeOnFreeMask) >> 11;
  139. }
  140.  
  141. inline Boolean WindowFlags::GetClosesDocument (void)
  142. {
  143.     return (fWindowFlagBits & kClosesDocumentMask) >> 10;
  144. }
  145.  
  146. inline Boolean WindowFlags::GetOpenInitially (void)
  147. {
  148.     return (fWindowFlagBits & kOpenInitiallyMask) >> 9;
  149. }
  150.  
  151. inline Boolean WindowFlags::GetMustAdaptToScreen (void)
  152. {
  153.     return (fWindowFlagBits & kMustAdaptToScreenMask) >> 8;
  154. }
  155.  
  156. inline Boolean WindowFlags::GetStagger (void)
  157. {
  158.     return (fWindowFlagBits & kStaggerMask) >> 7;
  159. }
  160.  
  161. inline Boolean WindowFlags::GetMustForceOnScreen (void)
  162. {
  163.     return (fWindowFlagBits & kMustForceOnScreenMask) >> 6;
  164. }
  165.  
  166. inline Boolean WindowFlags::GetVertCenter (void)
  167. {
  168.     return (fWindowFlagBits & kVertCenterMask) >> 5;
  169. }
  170.  
  171. inline Boolean WindowFlags::GetHorzCenter (void)
  172. {
  173.     return (fWindowFlagBits & kHorzCenterMask) >> 4;
  174. }
  175.  
  176. inline Boolean WindowFlags::GetFloats (void)
  177. {
  178.     return (fWindowFlagBits & kFloatsMask) >> 3;
  179. }
  180.  
  181. inline Boolean WindowFlags::GetHideOnSuspend (void)
  182. {
  183.     return (fWindowFlagBits & kHideOnSuspendMask) >> 2;
  184. }
  185.  
  186. inline Boolean WindowFlags::GetGenerateActivates (void)
  187. {
  188.     return (fWindowFlagBits & kGenerateActivatesMask) >> 1;
  189. }
  190.  
  191.  
  192.  
  193.  
  194. inline void WindowFlags::SetHasGoAway (unsigned short hasGoAway)
  195. {
  196.     fWindowFlagBits |= hasGoAway << 15;
  197. }
  198.  
  199. inline void WindowFlags::SetResizable (unsigned short resizable)
  200. {
  201.     fWindowFlagBits |= resizable << 14;
  202. }
  203.  
  204. inline void WindowFlags::SetDoFirstClick (unsigned short doFirstClick)
  205. {
  206.     fWindowFlagBits |= doFirstClick << 13;
  207. }
  208.  
  209. inline void WindowFlags::SetFreeOnClosing (unsigned short freeOnClosing)
  210. {
  211.     fWindowFlagBits |= freeOnClosing << 12;
  212. }
  213.  
  214. inline void WindowFlags::SetDisposeOnFree (unsigned short disposeOnFree)
  215. {
  216.     fWindowFlagBits |= disposeOnFree << 11;
  217. }
  218.  
  219. inline void WindowFlags::SetClosesDocument (unsigned short closesDocument)
  220. {
  221.     fWindowFlagBits |= closesDocument << 10;
  222. }
  223.  
  224. inline void WindowFlags::SetOpenInitially (unsigned short openInitially)
  225. {
  226.     fWindowFlagBits |= openInitially << 9;
  227. }
  228.  
  229. inline void WindowFlags::SetMustAdaptToScreen (unsigned short mustAdaptToScreen)
  230. {
  231.     fWindowFlagBits |= mustAdaptToScreen << 8;
  232. }
  233.  
  234. inline void WindowFlags::SetStagger (unsigned short stagger)
  235. {
  236.     fWindowFlagBits |= stagger << 7;
  237. }
  238.  
  239. inline void WindowFlags::SetMustForceOnScreen (unsigned short mustForceOnScreen)
  240. {
  241.     fWindowFlagBits |= mustForceOnScreen << 6;
  242. }
  243.  
  244. inline void WindowFlags::SetVertCenter (unsigned short vertCenter)
  245. {
  246.     fWindowFlagBits |= vertCenter << 5;
  247. }
  248.  
  249. inline void WindowFlags::SetHorzCenter (unsigned short horzCenter)
  250. {
  251.     fWindowFlagBits |= horzCenter << 4;
  252. }
  253.  
  254. inline void WindowFlags::SetFloats (unsigned short floats)
  255. {
  256.     fWindowFlagBits |= floats << 3;
  257. }
  258.  
  259. inline void WindowFlags::SetHideOnSuspend (unsigned short hideOnSuspend)
  260. {
  261.     fWindowFlagBits |= hideOnSuspend << 2;
  262. }
  263.  
  264. inline void WindowFlags::SetGenerateActivates (unsigned short generateActivates)
  265. {
  266.     fWindowFlagBits |= generateActivates << 1;
  267. }
  268.  
  269. //----------------------------------------------------------------------------------------
  270. // WMgrTWindow: Used by the window mapper
  271. //----------------------------------------------------------------------------------------
  272. struct WMgrTWindow
  273. {
  274.     TWindow* itsTWindow;
  275.     WindowRef itsWindow;
  276. };
  277.  
  278. typedef WMgrTWindow* WMgrTWindowPtr;
  279.  
  280. //----------------------------------------------------------------------------------
  281. // TWindow: Corresponds to a desktop Window. The outermost of a nested set of views.
  282. //----------------------------------------------------------------------------------
  283.  
  284. class TWindow : public TView, public MScriptableObject
  285. {
  286.     MA_DECLARE_CLASS;
  287.     
  288.     //------------------------------------------------------------------------------------
  289.     // Creation/ Destruction Methods 
  290.     //------------------------------------------------------------------------------------
  291.  
  292. public:
  293.  
  294.     TWindow();
  295.         // Constructor
  296.         
  297.     void IWindow(TDocument* itsDocument,
  298.                                 WindowRef itsWMgrWindow,
  299.                                 Boolean canResize,
  300.                                 Boolean canClose,
  301.                                 Boolean disposeOnFree);
  302.         // Initialize a window procedurally. 
  303.  
  304.     virtual WindowRef GetBehindWindowPtr();
  305.         // return the windowPtr in the windowlist behind which this window gets created 
  306.  
  307.     virtual ~TWindow();
  308.         // Frees the window if fDisposeOnFree is true, also deletes the window from the
  309.         // document if there is one, otherwise deletes it from the applications list of
  310.         // free windows. 
  311.  
  312.     virtual TObject* Clone();
  313.         // calls Inherited::Clone and then clones owned objects
  314.  
  315.     virtual void DoPostCreate(TDocument* itsDocument);    // Override
  316.         // sets the resize limits
  317.     
  318.     //------------------------------------------------------------------------------------
  319.     // Standard signature support.
  320.     //------------------------------------------------------------------------------------
  321.  
  322.     virtual IDType GetStandardSignature();    // override 
  323.         // Returns this class's standard signature.
  324.  
  325.     //------------------------------------------------------------------------------------
  326.     // Stream I/O protocol support.
  327.     //------------------------------------------------------------------------------------
  328.  
  329.     virtual void ReadFields(TStream* aStream);    // override 
  330.     
  331.     virtual void WriteFields(TStream* aStream);    // override 
  332.  
  333.     //------------------------------------------------------------------------------------
  334.     // Open/Close Methods 
  335.     //------------------------------------------------------------------------------------
  336.  
  337.     virtual void BeInDocument(TDocument* itsDocument); // override
  338.         // Assigns fDocument itsDocument by calling Inherited and then adds
  339.         // itself to the document's window list
  340.  
  341.     virtual void Open();
  342.         // Makes the window visible by showing it before calling Inherited::Open. 
  343.  
  344.     virtual void DoClose(CommandNumber aCommand,
  345.                          Boolean useAppleEvent = TRUE);
  346.         // Creates and posts a command which will close the window.  Pass a FALSE
  347.         // if the command is not to create an AppleEvent.
  348.  
  349.     virtual void Close();
  350.         // Calls Inherited::Close and the hides & deactivates the window. 
  351.  
  352.     virtual void CloseAndFree();
  353.         // Calls and free the window if fFreeOnCompletion. 
  354.  
  355.     virtual void CloseByUser(CommandNumber aCommandNumber);
  356.         // If the window is shown and it can be closed handles the closing. 
  357.         // Returns FALSE if the user cancels closing. 
  358.  
  359.     virtual void GoAwayByUser(const VPoint& theMouse);
  360.         // Responsible for calling CloseByUser. 
  361.  
  362.  
  363.     //------------------------------------------------------------------------------------
  364.     // Activation Methods 
  365.     //------------------------------------------------------------------------------------
  366.  
  367.     virtual void Activate(Boolean entering);
  368.         // Activate the window. 
  369.  
  370.  
  371.     //------------------------------------------------------------------------------------
  372.     // Size/ Location Methods 
  373.     //------------------------------------------------------------------------------------
  374.  
  375.     virtual void MoveByUser(const VPoint& theMouse);
  376.         // Handles the user moving the window by dragging the title bar, calls DragWindow
  377.         // to handle movement. 
  378.  
  379.     virtual void ResizeByUser(const VPoint& theMouse);
  380.         // Handles the user resizing the window by dragging the growbox, calls GrowWindow
  381.         // to handle movement and Resize to resize the window. 
  382.  
  383.     virtual void SetFrame(const VRect& newFrame, Boolean invalidate);
  384.         // Used to resize the window by setting its frame to the parameters
  385.         // passed in. 
  386.  
  387.     virtual void Zoom(short partCode);
  388.         // Responsible for actually handling the zooming of a window when the user clicks
  389.         // in the zoombox. 
  390.  
  391.     virtual void ZoomByUser(const VPoint& theMouse, short partCode);
  392.         // handles the user clicking in the zoombox to zoom the window, calls Zoom. 
  393.  
  394.     virtual void GetDynamicMoveBounds(CRect& moveBounds);
  395.         // returns bounds over which the window may be moved. Honors fMoveBounds when non-zero
  396.  
  397.     virtual void GetDynamicResizeLimits(CRect& resizeLimits);
  398.         // returns limits over which the window may be resized. Honors fResizeLimits when non-zero.
  399.  
  400.  
  401.     //------------------------------------------------------------------------------------
  402.     // Focusing Methods 
  403.     //------------------------------------------------------------------------------------
  404.  
  405.     virtual Boolean Focus();
  406.         // Attempts to set the Focus to the window, returns true if it succeeds, false if
  407.         // not. 
  408.  
  409.     virtual Boolean FocusOnSuperView();
  410.         // Attempts to set the Focus to our superview, returning true if it succeeds or
  411.         // false if not. 
  412.  
  413.  
  414.     //------------------------------------------------------------------------------------
  415.     // Drawing Methods 
  416.     //------------------------------------------------------------------------------------
  417.  
  418.     virtual void DrawResizeIcon();
  419.         // Draws the grow icon by calling the toolbox routine DrawGrowIcon. 
  420.  
  421.  
  422.     //------------------------------------------------------------------------------------
  423.     // Mouse Handling Methods 
  424.     //------------------------------------------------------------------------------------
  425.  
  426.     virtual Boolean HandleMouseDown(const VPoint& theMouse,
  427.                                            TToolboxEvent* event,
  428.                                            CPoint hysteresis,
  429.                                            EMouseDownType mouseDownType = kDragOrClick);
  430.         // Handles mouse downs in the window. 
  431.  
  432.     virtual short GetPartCode(const VPoint& theMouse);
  433.         // determines what part of the window theMouse is in 
  434.  
  435.     virtual Boolean HasPendingUpdate();
  436.         // Returns true if there is a pending update event for this window, false if not.
  437.  
  438.     virtual void BeginUpdate();
  439.         // Encapsulates the Toolbox BeginUpdate. 
  440.  
  441.     virtual void EndUpdate();
  442.         // Encapsulates the Toolbox EndUpdate. 
  443.  
  444.     virtual void Update();
  445.         // Handle the update region and drawcontents on this. 
  446.  
  447.     virtual void DoInvalidateRegion(const RgnHandle badRgn);
  448.         // If a WMgrWindow is available calls InvalRgn 
  449.  
  450.     virtual void DoValidateRegion(const RgnHandle goodRgn);
  451.         // If a WMgrWindow is available calls ValidRgn 
  452.  
  453.  
  454.     //------------------------------------------------------------------------------------
  455.     // Menu Handling Methods 
  456.     //------------------------------------------------------------------------------------
  457.  
  458.     virtual Boolean AllowsMenuAccess();
  459.         // By default returns true. 
  460.  
  461.     virtual void DoSetupMenus();
  462.         // If the window is not modal calls Inherited::DoSetupMenus. 
  463.  
  464.     virtual void DoMenuCommand(CommandNumber aCommandNumber);
  465.         // Handles closing the window. 
  466.  
  467.  
  468.     //------------------------------------------------------------------------------------
  469.     // Target and view management 
  470.     //------------------------------------------------------------------------------------
  471.  
  472.     virtual void DoEvent(EventNumber eventNumber,
  473.                                 TEventHandler* source,
  474.                                 TEvent* event);    // Override
  475.  
  476.     virtual void SetWindowTarget(TEventHandler* newTarget);
  477.         // Sets the window's fTarget to 'newTarget'. When the window is activated, 
  478.         // newTarget will become the target
  479.  
  480.     virtual TEventHandler* GetWindowTarget();
  481.         // Return the current fTarget of this window 
  482.  
  483.     virtual void RemovedASubView(TView* theSubView);
  484.         // Overridden to fix up the target, if the subview removed was the target 
  485.  
  486.  
  487.     //------------------------------------------------------------------------------------
  488.     // Cursor Handling 
  489.     //------------------------------------------------------------------------------------
  490.     
  491.     virtual Boolean HandlesCursor(); // OVERRIDE
  492.         // Returns true if fHandlesCursor is true, and the window is active, or
  493.         // fDoFirstClick is true 
  494.  
  495.     virtual Boolean LetsSubViewsHandleCursor(); // OVERRIDE
  496.  
  497.     virtual Boolean HandlesHelp(); // OVERRIDE
  498.         // Returns the value of fDoesHandleHelp 
  499.  
  500.     virtual Boolean LetsSubViewsHandleHelp(); // OVERRIDE
  501.  
  502.  
  503.     //------------------------------------------------------------------------------------
  504.     // Misc. Methods 
  505.     //------------------------------------------------------------------------------------
  506.  
  507.     virtual void AboutToLoseControl();
  508.         // called when the application is about to lose control 
  509.  
  510.     virtual void RegainControl();
  511.         // called when the application is regaining control 
  512.  
  513.     virtual void Show(Boolean state, Boolean redraw);
  514.         // Called to make the window visible or not based on 'state'. 
  515.  
  516.     virtual Boolean IsShown();
  517.         // Returns true if the window is currently shown. 
  518.  
  519.     virtual Boolean IsActive();
  520.         // Returns true if the window is currently active. 
  521.  
  522.     virtual void Select();
  523.         // Called to select the window. 
  524.  
  525.     virtual void SetTitle(const CStr255& newTitle); 
  526.         // Sets the windows title to 'newTitle'. 
  527.  
  528.     virtual void GetTitle(CStr255& theTitle); 
  529.         // Gets the current title of the window. 
  530.  
  531.     virtual void SetTitleForDoc(const CStr255& newDocTitle);// %%% AMB
  532.         // Called when the documents name is known or changed 
  533.  
  534.     virtual void AdaptToScreen();
  535.         // Resizes the window to fit the screen on which it is being displayed. 
  536.  
  537.     virtual void ForceOnScreen();
  538.         // ForceOnScreen gaurantees that some minimal drag area is accessible to the user,
  539.         // to be dragged to the desired location. 
  540.  
  541.     virtual void Center(Boolean horizontally,
  542.                                Boolean vertically,
  543.                                Boolean forDialog);
  544.         // Centers the window on the screen either horizontally, vertically or both. 
  545.  
  546.     virtual void SimpleStagger(CPoint delta,
  547.                                    short& counter);
  548.         // Handles the staggering of windows as they are opened. 
  549.  
  550.     virtual GrafPtr GetGrafPort();
  551.         // Returns the windows GrafPtr. 
  552.  
  553.     virtual GDHandle GetMaxIntersectedDevice(CRect& screenRect);
  554.         // Returns the screenRect of the most intersected device & its GDHandle, or if CQD
  555.         // isn't available it returns GetGrayRgn intersected with screenbits.bounds and
  556.         // NULL for the GDHandle. 
  557.  
  558.     virtual TWindow* GetWindow() const;
  559.         // Returns this. 
  560.  
  561.     virtual void SetResizeLimits(CPoint itsMinSize, CPoint itsMaxSize);
  562.         // Used to set the limits to which the window can be resized. 
  563.  
  564.     virtual Boolean RectInDrag(const CRect& whichRect);
  565.         // Returns true if any of the corner points of whichRect are draggable. 
  566.  
  567.     virtual Boolean IsHiddenOnSuspend();
  568.         // Returns true if this window gets hidden when the application is suspended. 
  569.  
  570.     virtual Boolean IsDismissed();
  571.         // Returns true if this dialog has been dismissed. 
  572.  
  573.     virtual void Dismiss(IDType dismisser, Boolean validate);
  574.         // dismiss the dialog that is currently being posed modally 
  575.  
  576.     virtual Boolean BuildWindowRegions(Boolean build);
  577.         // IF build=kBuild THEN ensures that the window regions are valid; sets
  578.         // fContentRegionInset, fContentDifference. Cleans up if necessary, when done with window
  579.         // regions. Returns the old state of the window regions. 
  580.  
  581.     virtual TDialogBehavior* GetDialogBehavior();
  582.         // Returns the windows dialog behavior, if any.
  583.         
  584.     virtual void SetModality(Boolean modal);
  585.         // Creates a TDialogBehavior object if necessary, and sets its modality.
  586.  
  587.     virtual void SetDialogItems(IDType  itsDefaultItem,
  588.                                        IDType  itsCancelItem);
  589.         // Creates a TDialogBehavior object if necessary, and sets its attributes.
  590.  
  591.         
  592.     virtual IDType PoseModally();
  593.         // poses this window in a modal state.
  594.  
  595.     virtual Boolean IsModal();
  596.         // Returns true if this window is modal.
  597.  
  598.     virtual Boolean IsInModalState();
  599.         // Returns true if this window is currently in a modal state.
  600.  
  601.     virtual void GetLocationAdjustment(CPoint& delta);
  602.  
  603.     virtual void GetStandardStateFrame(const VRect& boundingRect,
  604.                                                VRect& stdFrame);
  605.  
  606.     virtual void GetUserStateFrame(const VRect& boundingRect,
  607.                                            VRect& userFrame);
  608.  
  609.     //------------------------------------------------------------------------------------
  610.     // Scripting Support 
  611.     //------------------------------------------------------------------------------------
  612.  
  613.     virtual DescType GetSpecifierForm(); // override
  614.  
  615.     virtual long CountContainedObjects(DescType desiredType);
  616.  
  617.     virtual TCommandHandler* GetCommandContext(const CommandNumber aCommandNumber) const;
  618.  
  619.     virtual MScriptableObject* GetContainedObject(DescType desiredType,
  620.                                               DescType selectionForm,
  621.                                               const CAEDesc& selectionData);
  622.  
  623.     virtual Boolean GetObjectProperty(CAEDesc& thePropertyValue,
  624.                                     DescType whichProperty,
  625.                                     const CAEDesc& desiredType);
  626.  
  627.     virtual void GetSetPropertyInfo(DescType whichProperty,
  628.                                 CommandNumber& cmdNum,
  629.                                 Boolean& canUndo,
  630.                                 Boolean& causesChange,
  631.                                 TCommandHandler* &theContext);
  632.                                 
  633.     virtual void SetObjectProperty(const CAEDesc& thePropertyValue,
  634.                                     DescType whichProperty);
  635.  
  636.     virtual void DoAEClose(TAppleEvent* message,
  637.                            TAppleEvent* reply);
  638.  
  639.     virtual void DoAEMove(TAppleEvent* message,
  640.                           TAppleEvent* reply);
  641.  
  642.     virtual void DoAEPrint(TAppleEvent* message,
  643.                           TAppleEvent* reply);
  644.  
  645.     virtual void DoScriptCommand(CommandNumber    aCommandNumber,
  646.                                 TAppleEvent*     message,
  647.                                 TAppleEvent*     reply);
  648.     
  649.     void SetScriptingPrintHandler(TPrintHandler* printHandler);
  650.     
  651.     void ReleaseScriptingPrintHandler(TPrintHandler* printHandler);
  652.     
  653. #if qAttachable
  654.     virtual Boolean HandleOSAEvent(CommandNumber    aCommandNumber,
  655.                                     TAppleEvent*     message,
  656.                                     TAppleEvent*     reply);
  657. #endif
  658.         
  659. #if qDrag    
  660.     //------------------------------------------------------------------------------------
  661.     // Drag Support 
  662.     //------------------------------------------------------------------------------------
  663.         
  664.     virtual void RegisterDroppableView(TView* theView);
  665.     
  666.         // Droppable subviews register with the window.  A list of these views
  667.         // is maintained in fDroppableViewList
  668.         
  669.     virtual void UnregisterDroppableView(TView* theView);
  670.         
  671.         // Unregister a view when it is destroyed or loses its ability to receive drops
  672.         
  673.     virtual TView* MouseToDropTarget(CDragItemIterator&    dragItemIterator,
  674.                                     const CPoint&         globalMouse,
  675.                                     VPoint&                localMouse);
  676.         
  677.         // Returns the TView that would accept the current drag. Returns
  678.         // NULL if no eligible target exists.  If a target is located, localMouse is
  679.         // set to the mouse location in the target view's coordinate system
  680.         
  681.     virtual void DragEnteredWindow(CDragItemIterator& dragItemIterator);
  682.             // Perform any pre-flight necessary to handle tracking a drag
  683.         
  684.     virtual void DragLeftWindow();
  685.         // Perform any clean-up after a drag has exited
  686.         
  687. #endif // qDrag
  688.  
  689.  
  690. //----------------------------------------------------------------------------------------
  691. // static functions
  692. //----------------------------------------------------------------------------------------
  693. public:
  694.  
  695.     static RgnHandle GetUpdateRegion(WindowPtr theWindow);
  696.         // Return the correct updateRgn even if BeginUpdate has been called
  697.     
  698.     static RgnHandle GetVisRegion(GrafPtr theGrafPtr);
  699.         // Return the correct visRgn even if BeginUpdate has been called
  700.     
  701.     static Boolean IsGhostWindow(WindowRef window);
  702.  
  703.     static Handle GetAndLoadWDefProc(Handle windowDefProc);
  704.  
  705.     static void HighlightAndActivateWindow(WindowRef theWindow, Boolean activate);
  706.  
  707.     static TWindow* WMgrToWindow(WindowRef aWMgrWindow);
  708.         // Returns the window object that represents the given Window Manager window, or
  709.         // NULL if there is no window object.
  710.     
  711.     static void DeleteWindow(TWindow* aWindow);
  712.         // called when you have a new TWindow to track
  713.     
  714.     static void RegisterWindow(TWindow* aWindow);
  715.         // called when freeing a TWindow
  716.     
  717.     static Boolean IsDocumentWindow(WindowRef aWindow);
  718.     
  719.     static Boolean IsDialog(WindowRef window);
  720.     
  721.     static Boolean IsFloatWindow(WindowRef window);
  722.     
  723.     static Boolean IsSystemWindow(WindowRef window);
  724.     
  725.     static Boolean IsModalWindow(WindowRef window);
  726.     
  727.     static WindowRef GetLastFloatingWindowPtr();
  728.     
  729.     static WindowRef GetFirstFloatingWindowPtr();
  730.     
  731.     static void MAActivateWindow(WindowRef theWindow);
  732.     
  733.     static void MADeactivateWindow(WindowRef theWindow);
  734.     
  735.     static void MADragWindow(WindowRef windowToDrag, CPoint startPoint, const CRect& draggingBounds);
  736.     
  737.     // Added for 3.5
  738.     static void MASelectToolboxWindow(WindowRef windowToSelect);
  739.         // "Selects" windowToSelect by calling the toolbox routine SelectWindow. When any
  740.         // window is selected, it goes through here. We never call SelectWindow directly.
  741.     
  742.     static void MAShowWindow(WindowRef windowToShow);
  743.     
  744.     static void MAHideWindow(WindowRef windowToHide);
  745.     
  746.     static WindowRef MAFrontWindow();
  747.     
  748.     static WindowRef FreeIfWMgrWindow(WindowRef w,Boolean dispose);
  749.         // Calls DisposeWindow if dispose is true, else calls CloseWindow. Does nothing if w
  750.         // is NULL. Returns NULL for convenient assignment back to the reference passed in.
  751.  
  752. //----------------------------------------------------------------------------------------
  753. // data members
  754. //----------------------------------------------------------------------------------------
  755. public:
  756.  
  757.     CRect fMoveBounds;                            // bounds over which the window may be
  758.                                                 // moved. Any value that is zero will be
  759.                                                 // dynamically calculated. 
  760.  
  761.     CRect fResizeLimits;                        // limits over which the window may be
  762.                                                 // resized. Any value that is zero will be
  763.                                                 // dynamically calculated.  
  764.  
  765.     CPoint fContentRegionInset;                    // topleft inset of cont rgn in struc rgn
  766.  
  767.     CPoint fContentDifference;                    // total amount the content is less than
  768.                                                 // and offset into the structure (Accounts
  769.                                                 // for title bar, etc.) 
  770.     
  771.     TPrintHandler* fScriptingPrintHandler;        // Print handler to invoke when the window
  772.                                                 // receives a print apple event
  773.                                                                                                                                                                                                                             
  774.     TEventHandler* fTarget;                        // when this window is activated; the
  775.                                                 // TEventHandler to SetTarget on 
  776.  
  777.     WindowRef fWMgrWindow;                        // the window manager window Ptr 
  778.  
  779.     IDType fTargetID;                            // corresponding ID to fTarget 
  780.  
  781.     short fProcID;                                // the proc ID of the window 
  782.  
  783.     short fPreDocname;                            // amount of window title that precedes
  784.                                                 // the document name 
  785.  
  786.     short fConstTitle;                            // amount of the title name that is
  787.                                                 // constant 
  788.  
  789.     short        fStrListID;                        // window's title:    STR# rsrc id
  790.  
  791.     short        fIndex;                            // index into STR#
  792.  
  793.     Boolean fUpdating;                        // True when TWindow::Update has control.
  794.                                                 // Changes behaviour of TWindow::Focus to
  795.                                                 // clip TO the update region instead of
  796.                                                 // clipping OUT the update region 
  797.  
  798.     Boolean fIsActive;                            // is this window active 
  799.  
  800.     Boolean fIsResizable;                        // is this window resizeable 
  801.  
  802.     Boolean fIsClosable;                        // is this window closable 
  803.  
  804.     Boolean fFreeOnClosing;                        // should this window free itself when it
  805.                                                 // closes 
  806.  
  807.     Boolean fDisposeOnFree;                        // should the window manager window be
  808.                                                 // disposed when this window frees 
  809.  
  810.     Boolean fClosesDocument;                    // does this window close the document 
  811.  
  812.     Boolean fOpenInitially;                        // should this window be opened when its
  813.                                                 // document is asked to show its windows 
  814.  
  815.     Boolean fDoFirstClick;                        // should a click in this window not only
  816.                                                 // select it if it is inactive but also be
  817.                                                 // sent to its contents 
  818.  
  819.     Boolean fFloats;                            // does this window float above
  820.                                                 // non-floating windows
  821.  
  822.     Boolean fHideOnSuspend;                        // does this window get hid on suspend? 
  823.  
  824.     Boolean fWasHiddenOnSuspend;                // True if this window was hid on suspend
  825.  
  826.     Boolean fGenerateActivates;                    // a flag indicating whether or not
  827.                                                 // TWindow::Show should generate the
  828.                                                 // necessary activate events 
  829.  
  830.     Boolean fMustAdapt;                            // does this window require adaption to
  831.                                                 // the screen 
  832.  
  833.     Boolean fMustHorzCenter;                    // does this window require centering
  834.                                                 // horizontally 
  835.  
  836.     Boolean fMustVertCenter;                    // does this window require centering
  837.                                                 // vertically 
  838.  
  839.     Boolean fMustStagger;                        // does this window require staggering 
  840.  
  841.     Boolean fMustForceOnScreen;                    // does this window require forcing on the
  842.                                                 // screen 
  843.  
  844.     Boolean fAdapted;                            // has this window's size ever been
  845.                                                 // adapted to the screen 
  846.  
  847.     Boolean fHorzCentered;                        // has this window been centered
  848.                                                 // horizontally 
  849.  
  850.     Boolean fVertCentered;                        // has this window been centered
  851.                                                 // vertically 
  852.  
  853.     Boolean fStaggered;                            // has this window been staggered 
  854.  
  855.     Boolean fForcedOnScreen;                    // has this window been forced on the
  856.                                                 // screen 
  857.  
  858. #if qDrag    
  859.     //------------------------------------------------------------------------------------
  860.     // Drag and Drop Data
  861.     //------------------------------------------------------------------------------------
  862.     
  863.     EDragCallbackStatus fDragCallbackStatus;    // enumerated type indicating whether or
  864.                                                 // not drag manager callbacks have been
  865.                                                 // installed for the window.
  866.  
  867.     TList*                fDroppableViewList;        // list of subviews that are droppable
  868.                                                 
  869.     TDynamicArray*        fDropStatusCache;        // cache that maps to fDroppableViewList
  870.                                                 // that indicates whether views can or
  871.                                                 // can't receive the current drag
  872.  
  873. #endif // qDrag
  874.                                                 
  875. //----------------------------------------------------------------------------------------
  876. // static data members
  877. //----------------------------------------------------------------------------------------
  878. public:
  879.     static short gStandardWindowStaggerCount;                    // Used to stagger windows created from
  880.                                                 // templates 
  881. protected:
  882.     static Boolean pInBeginUpdate;
  883.     static GrafPtr pInBeginUpdateWindowPtr;
  884.     
  885.     static RgnHandle pSavedUpdateRegion;
  886.     static RgnHandle pSavedVisRegion;
  887.     static CPoint pSavedVisRegionOriginalOffset;
  888.  
  889.     static TDynamicArray* gWindows;
  890. };
  891.  
  892. //----------------------------------------------------------------------------------------
  893. // TCloseWindowCommand: Tells the application to close a window
  894. //----------------------------------------------------------------------------------------
  895.  
  896. class TCloseWindowCommand : public TCommand
  897. {
  898.     MA_DECLARE_CLASS;
  899.     
  900. public:
  901.     TCloseWindowCommand();
  902.         // Constructor
  903.     virtual ~TCloseWindowCommand();
  904.         // Destructor
  905.         
  906.     void ICloseWindowCommand(CommandNumber itsCommandNumber,
  907.                              TWindow* itsWindow);
  908.     void ICloseWindowCommand(TWindow* itsWindow,
  909.                              TAppleEvent* message,
  910.                              TAppleEvent* reply);
  911.         // Initialize the CloseWindowCommand procedurally. 
  912.         
  913.     virtual TAppleEvent* MakeAppleEvent();
  914.  
  915.     virtual void DoIt();
  916.         // tell the application to close a window. 
  917. //----------------------------------------------------------------------------------------
  918. // data members
  919. //----------------------------------------------------------------------------------------
  920. public:
  921.     TWindow* fWindow;    // The window to close
  922.  
  923. protected:
  924.     TAppleEvent* fMessage;
  925.     TAppleEvent* fReply;
  926. };
  927.  
  928. #endif
  929.  
  930.  
  931.